#include <libavformat/avformat.h>

int main(int argc, char const *argv[])
{
    int ret;

    AVFormatContext *input_server_ctx = NULL;
    AVDictionary *in_opts = NULL;

    // av_dict_set(&in_opts, "timeout", "2", 0);
    av_dict_set(&in_opts, "listen", "2", 0);

    avformat_open_input(&input_server_ctx, "rtmp://0.0.0.0:1935/stream/live", NULL, &in_opts);
    if ((ret = avformat_find_stream_info(input_server_ctx, 0)) < 0)
    {
        fprintf(stderr, "Failed to retrieve input stream information");
        return 0;
    }
    av_dump_format(input_server_ctx, 1, "rtmp://0.0.0.0:1935/stream/live", 0);
    while (1)
    {
        AVPacket pkt;
        av_read_frame(input_server_ctx, &pkt);
        printf("got packet\n");
    }

    return 0;
}
